<script>

    var regexp = /<([^>]+)>[^<]*<\/\1>/g; // g 必须标明，否则死循环

    var str = "<b>bold</b><span>12</span>"

    while (true) {
        var result = regexp.exec(str)

        if (!result) break

        console.log(result, regexp.lastIndex, regexp.source)
        // break
    }
    console.log(regexp.lastIndex, regexp.source)
</script>